#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>

int multiply(int A, int B)
{
    if (B > A)
    {
        if (A == 0)
        {
            return A;
        }
        return multiply(A - 1, B) + B;
    }
    else
    {
        if (B == 0)
        {
            return B;
        }
        return multiply(A, B - 1) + A;
    }
}

#include <stdio.h>

#include <stdio.h>

int main() {
    int n = 0;
    scanf("%d", &n);
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 7 == 0 || i % 10 == 7 || i / 10 % 10 == 7 || i / 100 % 10 == 7 || i / 1000 % 10 == 7)
        {
            count++;
        }

    }

    printf("%d", count);
}
}